import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    tabList: [
      {
        title: "首页",
        path: "/home/dashboard",
      },
      {
        title: "新生报名",
        path: ''
      }
    ]

  },
  mutations: {
    // 添加标签项
    // setTabList: ({ tabList }, data) => {
    //   let flag = false
    //   tabList.forEach(el => {
    //     if (el.title == data.title) {
    //       flag = true
    //     }
    //   })
    //   if (!flag) {
    //     // 没找到
    //     tabList.push(data)
    //   }
    // }

    setTabList: ({ tabList }, data) => {
      let flag = false
      tabList.forEach(el => {
        if (el.title == data.title) {
          flag = true
        }
      })
      if (!flag) {
        tabList.push(data)
      }
    },
    //删除标签项目
    delTabItem: ({ tabList }, index) => {
      tabList.splice(index, 1)
    }


  },
  actions: {
  },
  modules: {
  }
})
